From 7c2a69c9b48c1930dc3f7cbef20d6479b3047ca2 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Mon, 29 Jul 2024 17:13:30 +0700
Subject: <iman> update category lob

---
 src/pages/shop/lob/[slug].jsx | 49 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

(limited to 'src/pages/shop/lob/[slug].jsx')

diff --git a/src/pages/shop/lob/[slug].jsx b/src/pages/shop/lob/[slug].jsx
index 2153b565..cdaf3c91 100644
--- a/src/pages/shop/lob/[slug].jsx
+++ b/src/pages/shop/lob/[slug].jsx
@@ -24,8 +24,55 @@ export default function CategoryDetail() {
   const categoryName = getNameFromSlug(slug);
   const lobId = getIdFromSlug(slug);
   const q = router?.query.q || null;
+
+  useEffect(() => {
+    if(router.pathname.includes('lob')){
+      const loadProduct = async () => {
+        const lobData = await odooApi('GET', `/api/v1/lob_homepage/${lobId}/category_id`);
+         
+        if (lobData) {
+          setDataLob(lobData);
+        }
+      };
+      loadProduct();
+      
+    }
+  }, [lobId]);
+
+  useEffect(() => {
+     if (router.pathname.includes('lob')){
+      
+      const fetchCategoryData = async () => {
+        if (dataLob[0]?.categoryIds) {
+          
+          for (const cate of dataLob[0].categoryIds) {
+           
+            dataIdCategories.push(cate.childId)
+          }
+          
+        
+          setData(dataIdCategories.flat())
+         
+          // const newQuery = {
+          //   fq: `category_id_ids:(${mergedArray.join(' OR ')})`,
+          //   category : router.query.category? router.query.category : '',
+          //   page : router.query.page? router.query.page : 1,
+          //   brand : router.query.brand? router.query.brand : '',
+          //   priceFrom,
+          //   priceTo,
+          //   limit,
+          //   orderBy
+          // };
+       
+          // setFinalQuery(newQuery);
+         
+        }
+      };
+      fetchCategoryData();
+    }
+  }, [dataCategoriesProduct, dataLob]);
   const query = {
-    fq: `id:${lobId}`,
+    fq: `category_id_ids:(${data.join(' OR ')})`,
     page,
   };
   if (q) {
-- 
cgit v1.2.3

